package com.rchat.pocmini.activity.recharge;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.rchat.pocmini.R;

import java.util.List;

/**
 * Created by ljd on 2017/9/27.
 */

public class RechargeResultAdapter extends BaseAdapter {

    private List<com.rchat.pocmini.bean.RechargeResultBean.DataBean.OrdersBean> data;
    private Context context;
    private LayoutInflater inflater;

    public RechargeResultAdapter(List<com.rchat.pocmini.bean.RechargeResultBean.DataBean.OrdersBean> data, Context context) {
        this.data = data;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.recharge_result_item_layout, null);
            holder = new ViewHolder();
            holder.tvGoodsName = (TextView) convertView.findViewById(R.id.tv_goods_name);
            holder.tvMoney = (TextView) convertView.findViewById(R.id.tv_money);
            holder.tvRechargeDealTime = (TextView) convertView.findViewById(R.id.tv_recharge_time);
            holder.tvWXPayId = (TextView) convertView.findViewById(R.id.tv_wx_pay_id);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final com.rchat.pocmini.bean.RechargeResultBean.DataBean.OrdersBean bean = data.get(position);
        holder.tvGoodsName.setText(bean.getGoodsName());
        holder.tvRechargeDealTime.setText(bean.getTimeEnd());
        holder.tvMoney.setText(bean.getPrice() + "");
        holder.tvWXPayId.setText(bean.getTransactionId());
        return convertView;
    }

    private static class ViewHolder {
        private TextView tvGoodsName;
        private TextView tvMoney;
        private TextView tvRechargeDealTime;
        private TextView tvWXPayId;
    }

}
